package com.dx.mes.common.core.his;

import com.dx.mes.common.bean.entity.HisXml;
import com.dx.mes.common.core.rabbitmq.RabbitmqManager;
import com.dx.mes.common.core.redis.RedisManager;
import com.dx.mes.common.transcoder.util.ObjectTranscoder;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class HistoryManager {
	/*@Resource
	private RedisManager redisManager;
	@Resource
	private RabbitmqManager rabbitmqManager;
	
	public static final String RETURN_CODE_DEF_XML = "0000000";
	
	public boolean isTransactionSuccessed(String rtnMessage) {
		return (rtnMessage.indexOf(RETURN_CODE_DEF_XML) != -1);
	}

	public void sendHistoryMessageToRabbitMQ(String evt_no) {
		Jedis jedis = null ;
		List<HisXml> hisXmlList = new ArrayList<HisXml>();
		try {
			jedis = redisManager.getJedis();
    		String redisKey = "lodhis_" + evt_no;
    		byte[] bs = jedis.get(redisKey.getBytes());
			if(bs != null){
				hisXmlList = (List<HisXml>) ObjectTranscoder.deserialize(bs);
				for(int i=0; i<hisXmlList.size();i++){
					HisXml hisXml = hisXmlList.get(i);
					rabbitmqManager.setMessage(hisXml.getTableHistoryConfig().getQueueName(), hisXml.getXml());
				}
				jedis.del(redisKey.getBytes());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			redisManager.returnResource(jedis);//释放redis实例
		}
	}*/
}
